package com.xjh.utils.exception;


import com.xjh.utils.enumutils.IBaseEnum;

/**
 * 定义异常基类
 *
 * @author kevin
 * @company 湖南省安第斯信息科技有限公司, 版权所有
 * @date 2021/3/26
 */
public class BaseException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /** 状态码 */
    private String code;

    /** 提示信息 */
    private String msg;

    /** 返回数据 */
    private Object data;

    public BaseException(IBaseEnum status) {
        super(status.getCode());
        this.code = status.getCode();
        this.msg = status.getMsg();
    }

    public BaseException(IBaseEnum status, Object data) {
        this(status);
        this.data = data;
    }

    public BaseException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BaseException(String code, String msg, Object data) {
        this(code, msg);
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "BaseException{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                '}';
    }
}
